package cn.tedu.blog.server.repository;

import cn.tedu.blog.server.pojo.entity.ArticleForElastic;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ArticleForElasticRepository extends ElasticsearchRepository<ArticleForElastic, Long> {
    
    @Query("{\n" +
            "    \"bool\": {\n" +
            "      \"should\": [\n" +
            "        { \"match\": { \"title\": \"?0\"}},\n" +
            "        { \"match\": { \"brief\": \"?0\"}},\n" +
            "        { \"match\": { \"tags\": \"?0\"}}\n" +
            "        ]\n" +
            "     }\n" +
            "}")
    Page<ArticleForElastic> queryArticle(String keyword, Pageable pageable);
}
